home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7462 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.3 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.pl1,comp.lang.c
  4. Subject: Re: PL/I and C
  5. Date: 26 Feb 1996 13:16:15 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4gt0tv$826@solutions.solon.com>
  8. References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <4grhtv$s31@goanna.cs.rmit.EDU.AU>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <4grhtv$s31@goanna.cs.rmit.EDU.AU>,
  12. ++           robin <rav@goanna.cs.rmit.EDU.AU> wrote:
  13. >---The basic operations of string-handling are done somewhat
  14. >clumsily in C -- catenation is a simple infix operation
  15. >in PL/I, but you must use a function in C, and then it
  16. >catentates the second operand to the first.  Nothing like
  17. >c = d || e;
  18. >(And what happens when, in strcat(s1, s2), the sum of the lengths
  19. >of s1 and s2 exceeds the declaration for s1?!?!?
  20.  
  21. Then you invoke undefined behavior, and your code was illegal.  :)
  22.  
  23. Yes, C's string handling is primitive.  It also has no hidden overhead.
  24.  
  25. >---again, for comparison, IF s1 > s2 THEN . . .  becomes
  26. >strcmp(s1, s2) . . . which yields neg, 0, or pos . . .
  27. >which leads to IF strcmp(s1, s2) > 0 . . .
  28. >which is scarcely intuitive [shades of the arcane FORTRAN
  29. >arithmetic IF].
  30.  
  31. I would kill for arithmetic if, simply because I frequently want to do
  32. one of three things bsed on the sign of an expression.
  33.  
  34. Once again, C has no hidden overhead, but has primitive functions.  And?
  35.  
  36. >   I'd agree with the statement about built-in functions.
  37. >PL/I for AIX and OS/2 now have BIFs for searching for specific
  38. >characters (SEARCH) either from the right or from the left,
  39. >searching for the absence of specififc characters (VERIFY)
  40. >from the right or left.
  41.  
  42. strchr, strrchr, strspn, strcspn, strpbrk.
  43.  
  44. >   Furthermore INDEX, SEARCH, SEARCHR, VERIFY and VERIFYR
  45. >can start the search at any specified position (the three-
  46. >argument versions).
  47.  
  48. Same functions in C, you just use (s + 2) to start 2 positions in.  :)
  49.  
  50. >   There are several functions for centering text, & trimming
  51. >given characters from either or both ends of a string.
  52.  
  53. sprintf.
  54.  
  55. >   And what happens when you actually w*a*n*t a zero byte in your
  56. >C character string?
  57.  
  58. All C character strings have a zero byte in them.  It's at the end.
  59. (But it *is* a part of the string, so far as I can tell.)
  60.  
  61. If you want an object which has characters possibly including NUL bytes,
  62. but is otherwise like a string, feel free to make one; it's trivial.
  63. It's just more expensive to run.
  64.  
  65. This is silly, though.  C is a low-level language by modern standards.
  66. So?  It's a design call.  You choose a language that meets your needs.  C
  67. meets my needs because it's available for the machines I want to use.
  68.  
  69. Let's try to keep the inter-language flame wars at a minimum, and if nothing
  70. else, let's try to keep it so that only people who know C very well and are
  71. comfortable with the whole library are discussing C's merits, and ditto
  72. for PL/I.  I certainly don't have the qualifications to bash PL/I, and I doubt
  73. you have the qualifications to bash C.  :)
  74.  
  75. (I can bash C, I just don't really want to.)
  76.  
  77. -s
  78. -- 
  79. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  80. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  81. FUCK the communications decency act.  Goddamned government.  [literally.]
  82. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  83.